package org.xutils.xutillearn.presenter.presenterImpl;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;

import org.xutils.xutillearn.R;
import org.xutils.xutillearn.bean.LearnListItem;
import org.xutils.xutillearn.model.MainModel;
import org.xutils.xutillearn.model.modelImpl.MainModelImpl;
import org.xutils.xutillearn.presenter.MainPresenter;
import org.xutils.xutillearn.ui.iview.IMainView;

import java.io.InputStream;
import java.util.List;

/**
 * Created by yangmuyi on 16/4/12.
 */
public class MainPresenterImpl implements MainPresenter {

    IMainView iMainView;
    MainModel mainModel;

    public MainPresenterImpl(IMainView view){
           iMainView = view;
           mainModel = new MainModelImpl();
    }

    @Override
    public void showLessonList() {
        InputStream inputStream = iMainView.getContext().getResources().openRawResource(R.raw.learnlist);
        List<LearnListItem> list = mainModel.getLearnItemList(inputStream);
        iMainView.showLessonList(list);
    }

    @Override
    public void onLearnListItemClick(LearnListItem item) {
        String pkgName = item.getPkgName();
        String className = item.getClassName();
        ComponentName componentName = new ComponentName(pkgName,className);
        Intent intent = new Intent();
        intent.setComponent(componentName);

    }


}
